﻿using System;
using System.Net.Mail;

namespace ValidationWebForms.Contact
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            MailAddress from = new MailAddress
                (this.txtEmail.Text, this.txtName.Text);
            MailAddress to = new MailAddress("keyvan@wrox.com");

            MailMessage mail = new MailMessage(from, to);
            mail.Subject = this.txtSubject.Text;
            mail.Body = this.txtBody.Text;

            SmtpClient smtp = new SmtpClient("mail.wrox.com");
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.Send(mail);
        }
    }
}
